import {dictDictUrl, dictItemUrl} from "@/config/env";
import startSearchModel from "@/config/startSearchModel";

export default () => {
    return {
        index: true,
        submitText: '修改',
        size: 'default',
        labelWidth: 130,
        // menuType: 'menu',
        menuAlign: 'center',
        menuPosition: "right",
        searchIndex: 2,
        searchMenuSpan: 6,
        searchIcon: true,
        addBtn: true,
        editBtn: true,
        delBtn: true,
        permissionBtn: {
            addBtn: 'start:act:fun:def:add',
            editBtn: 'start:act:fun:def:edit',
            viewBtn: 'start:act:fun:def:info',
            delBtn: 'start:act:fun:def:delete',
        },
        column: [
            {
                label: 'id',
                span: 12,
                prop: 'id',
                align: "left",
                hide: true,
                display: false,
            },
            {
                label: '类别',
                prop: 'funCategoryCode',
                span: 24,
                type: "select",
                filterable: true,
                dicUrl: dictItemUrl,
                dicQuery: {
                    dictCode: 'procFunDefCategory'
                },
                props: {
                    label: "dictName",
                    value: "dictVal",
                },
                hide: true,
                rules: [{
                    required: true,
                    trigger: "blur"
                }]
            },
            {
                label: '名称',
                prop: 'funName',
                search: true,
                searchModel: startSearchModel.LIKE,
                span: 24,
                maxlength: 50,
                showWordLimit: true,
                rules: [{
                    required: true,
                    trigger: "blur",
                    message: "请输入名称"
                }]
            },
            {
                label: '流程范围',
                prop: 'procElementType',
                search: true,
                span: 24,
                type: "select",
                dicData: [
                    {label: "流程", value: "process"},
                    {label: "用户任务", value: "userTask"},
                ],
                rules: [{
                    required: true,
                    trigger: "blur",
                    message: "请输入名称"
                }]
            },
            {
                label: '编码',
                prop: 'funCode',
                search: true,
                maxlength: 50,
                showWordLimit: true,
                searchModel: startSearchModel.LIKE,
                editDetail: true,
                span: 24,
                rules: [{
                    required: true,
                    trigger: "blur",
                    message: "请输入编码"
                }]
            },
            {
                label: '配置UI显示类型',
                prop: 'funConfUiType',
                type: "select",
                dicData: [
                    {label: "单行文本框", value: "input"},
                    {label: "多行文本框", value: "textarea"},
                    {label: "单选框", value: "radio"},
                    {label: "多选框", value: "checkbox"},
                    {label: "下拉选择框", value: "select"},
                ],
                control: function (val) {
                    let result = {}
                    result.funDefVal = {}
                    result.funDefVal.type = val
                    result.dictCode = {}
                    if (!result.funDefVal.type || result.funDefVal.type.length < 1) {
                        result.funDefVal.type = "input"
                    }
                    result.dictCode.display = !['input', 'textarea'].includes(result.funDefVal.type)
                    return result
                },
                span: 24,
                rules: [{
                    required: true,
                    trigger: "blur",
                    message: "请选择配置UI显示类型"
                }]
            },
            {
                label: '字典',
                prop: 'dictCode',
                span: 24,
                type: "select",
                dicUrl: dictDictUrl,
                clearable: true,
                filterable: true,
                hide: true,
                search: true,
                cascader: ['funDefVal'],
                control: function (val, form) {
                    let result = {}
                    result.funDefVal = {}
                    result.funDefVal.dicQuery = {}
                    result.funDefVal.dicQuery.dictCode = val
                    return result;
                },
                props: {
                    label: "dictName",
                    value: "dictCode",
                },
                rules: [{
                    required: true,
                    trigger: "blur"
                }]
            },
            {
                label: '默认值',
                prop: 'funDefVal',
                filterable: true,
                dicUrl: dictItemUrl,
                dicQuery: {
                    dictCode: ''
                },
                props: {
                    label: "dictName",
                    value: "dictVal",
                },
                maxlength: 200,
                showWordLimit: true,
                span: 24,
            },
            {
                label: '描述',
                prop: 'funDescription',
                overHidden: true,
                type: "textarea",
                maxlength: 200,
                span: 24,
                showWordLimit: true,

            },
        ]
    }
}
